package features.advance.leetcode.util;

import org.springframework.util.StringUtils;

public class StringUtil extends org.springframework.util.StringUtils {


    public static int[] parseStrToArr(String str){
        StringBuilder sb = new StringBuilder();
        char pre = 0;
        int size = 1;
        for (int i = 0; i < str.length(); i++) {
            if (44 == str.charAt(i)){
                size++;
            }
        }
        int[] arr = new int[size];

        for (int i = 1,j=0; i < str.length() - 1; i++) {
            char c = str.charAt(i);
            if (44 == c){
                // ',' = 44
                arr[j++] = Integer.parseInt(sb.toString().trim());
                sb = new StringBuilder();

            }else {
                sb.append(c);

            }
            if (i == str.length() - 2){
                arr[j] = Integer.parseInt(sb.toString().trim());
            }


        }
        return arr;
    }
}
